package com.ecarx.camera;

import android.app.Application;

import com.ecarx.camera.constant.Constants;
import com.ecarx.camera.service.DvrStateService;
import com.ecarx.camera.utils.Utils;
import com.ecarx.camera.worker.car.aosp.AospCarManager;
import com.jeremyliao.liveeventbus.LiveEventBus;
import com.jeremyliao.liveeventbus.utils.AppUtils;
import com.otaliastudios.cameraview.CameraLogger;

public class MainApplication extends Application {

    @Override
    public void onCreate() {
        super.onCreate();
        DvrStateService.startIfNotRunning(this);
        Utils.init(this);
        initLiveEvent();
        initCameraViewLog();
        AospCarManager.get().init();
    }

    /**
     * 初始化LiveEvent
     */
    private void initLiveEvent() {
        AppUtils.init(this);
        LiveEventBus.config().setContext(this).enableLogger(false);
    }

    /**
     * 初始化CameraView的日志
     */
    private void initCameraViewLog() {
        CameraLogger.setLogLevel(Constants.CAMERA_VIEW_VERBOSE_LOG ? CameraLogger.LEVEL_VERBOSE : CameraLogger.LEVEL_ERROR);
    }
}
